package com.emily.test.service.impl;

import com.emily.test.mapper.ONewsMapper;
import com.emily.test.model.ONews;
import com.emily.test.service.ONewsService;
import com.emily.test.utils.ConstentUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service("oNewsServiceAgent")
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,timeout=36000,rollbackFor=Exception.class)
public class ONewsServiceImpl implements ONewsService {
    @Resource
    private ONewsMapper oNewsMapper;

    @Override
    public List<ONews> selectNewsListByCondition(ONews oNews) {
        if(!ConstentUtil.isEmpty(oNews.getState())){
            return oNewsMapper.selectNewsListByConditionWithInDel(oNews);
        }
        return oNewsMapper.selectNewsListByConditionWithOutDel(oNews);
    }

    @Override
    public int insertNews(ONews oNews) {
        return oNewsMapper.insertSelective(oNews);
    }

    @Override
    public int updateNews(ONews oNews) {
        return oNewsMapper.updateNews(oNews);
    }

    @Override
    public int updateNewsListByIds(List<ONews> oNewsList) {
        return oNewsMapper.updateNewsListByIds(oNewsList);
    }

    @Override
    public List<ONews> selectSomeNewNewsListByCondition(ONews oNews, Integer total) {
        return oNewsMapper.selectSomeNewNewsListByCondition(oNews,total);
    }
}
